{include file="Public:header" /}
<div class="bar bar-nav">
    <h1 class="title">我的预约</h1>
    <i class="icon icon-left" onclick="window.history.go( - 1);"></i>
</div>
<div class="content">
    <div class="content-block row in_tab_list">
        <div class="tab in_hot_box activity_1">
            {if condition="$make_users_show"}
            <div class="row discuss expert_discuss no-border" style="margin-top:0;">
                <div class="col-100">
                    <div class="content-padded">
                        <div class="list-block media-list" style="margin-top:0;">
                            <ul  id="all_yuyue">
                                {foreach name="make_users" item="make_users" key="mm"}
                                <li class="item-content">
                                    <div class="item-media" style="min-width: 60px;">
                                        <img src="{$make_users['head_img']}">
                                    </div>
                                    <div class="item-inner">
                                        <a href="{:U('Apply/expert_page',array('id'=>$make_users['apply_id']))}">
                                            <div class="item-title-row">
                                                <div class="item-title">{$make_users['name']}
                                                    <font>预约时间
                                                    {if condition="$make_users['select_time'] eq 1"}星期一{/if}
                                                    {if condition="$make_users['select_time'] eq 2"}星期二{/if}
                                                    {if condition="$make_users['select_time'] eq 3"}星期三{/if}
                                                    {if condition="$make_users['select_time'] eq 4"}星期四{/if}
                                                    {if condition="$make_users['select_time'] eq 5"}星期五{/if}
                                                    {if condition="$make_users['select_time'] eq 6"}星期六{/if}
                                                    {if condition="$make_users['select_time'] eq 0"}星期日{/if}
                                                    </font>

                                                </div>
                                            </div>
                                            <p>专家电话：{$make_users['mobile']} </p>
                                            <div class="item-subtitle">预约地点：{$make_users['address']}</div>
                                        </a>
                                        {switch name="make_users['status']"}
                                        {case value='1'}
                                        <a style="display: inline-block;float: left;margin-top: 10px;" id="success_yuyue" onclick="success_yuyue(this, {$make_users['id']});" class="button button-fill">结束预约</a>
                                        <a style="display: inline-block;float: right;margin-top: 10px;" id="release_yuyue" onclick="release_yuyue(this, {$make_users['id']});" class="button button-fill">取消预约</a>
                                        <a style="display: none;float: right;background: #ccc;margin-top: 10px;" id="release" class="button button-fill">已取消</a> 
                                        <a style="display: none;float: right;background: #ccc;margin-top: 10px;" id="success" class="button button-fill">已完成</a>
                                        <a style="display: none;float: left;margin-top: 10px;" id="discuss" href="{:U('Apply/discuss_list',array('id'=>$make_users['make_id']))}" class="button button-fill">评论</a>
                                        {/case}
                                        {case value='2'}
                                        <a style="display: inline-block;float: right;background: #ccc;margin-top: 10px;" class="button button-fill">已完成</a>
                                        <a style="display: inline-block;float: left;margin-top: 10px;" href="{:U('Apply/discuss_list',array('id'=>$make_users['make_id']))}" class="button button-fill">评论</a>
                                        {/case}
                                        {case value='3'}<a style="display: inline-block;float: right;background: #ccc;margin-top: 10px;" class="button button-fill">已取消</a> {/case}
                                        {/switch}
                                    </div>

                                </li>

                                {/foreach}

                            </ul>

                        </div>
                    </div>

                </div>
            </div>

            <div class="infinite-scroll-preloader" id="all_quan" style="display:none;">
                <div class="preloader"></div>
            </div>
            <p onclick="ajax_sourch_submit();" class="all_more" id="load_more"><span class="icon icon-down"></span> 点击加载更多...</p>
            {else/}
            <p id="load_more"> 暂无数据！</p>
            {/if}
        </div>

    </div>
</div>

{include file="Public:footer" /}
<script>
            var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
                    paginationClickable: true
            });</script>
<script>
            var page = 1;
            /*** ajax 提交表单 查询更多列表信息*/
                    function ajax_sourch_submit()
                    {
                    $("#all_quan").show();
                            page += 1;
                            $.ajax({
                            type : "GET",
                                    //url:"/index.php?m=Mobile&c=User&a=collect_list&is_ajax=1&p="+page,//+tab,			
                                    url:"/Apply/expert_discuss/is_ajax/1/p/" + page, //+tab,
//			data : $('#filter_form').serialize(),// 你的formid 搜索表单 序列化提交
                                    success: function(data)
                                    {
                                    $("#all_quan").hide();
                                            if ($.trim(data) == ''){
                                    $('.all_more').hide();
                                    } else{
                                    $("#all_yuyue").append(data);
                                    }
                                    }
                            });
                    }

            //结束预约
            function success_yuyue(obj, id){
            Zepto.confirm('请确认是否参与了该预约，结束之后无法恢复！', '温馨提示', function(){
            $.ajax({
            url:"{:U('Apply/success_yuyue')}",
                    type:'post',
                    dataType:'json',
                    data:{id:id},
                    success:function(data){
                    if (data.status == 1){
                    $(obj).hide();
                            $('#release_yuyue').hide();
                            $('#success').show();
                            $('#discuss').show();
                            Zepto.toast(data.message, 2000, function(){
                            location.reload();
                            });
                            return false;
                    } else if (data.status == 2){
                    Zepto.toast(data.message, 2000, 'success top');
                            return false;
                    }
                    }
            });
            });
            }

            //取消预约
            function release_yuyue(obj, id){
            $.ajax({
            url:"{:U('Apply/release_yuyue')}",
                    type:'post',
                    dataType:'json',
                    data:{id:id},
                    success:function(data){
                    if (data.status == 1){
                    $(obj).hide();
                            $('#success_yuyue').hide();
                            $('#release').show();
                            Zepto.confirm(data.message, '温馨提示', function(){
                            location.reload();
                            });
                            return false;
                    } else if (data.status == 2){
                    Zepto.toast(data.message, 2000, 'success top');
                            return false;
                    }

                    }
            });
            }
</script>
</body>

</html>